<?php
namespace App\Services\Classes;

use Monolog\Handler\StreamHandler;
use Monolog\Logger;

class Log{

    private $log;

    public function __construct()
    {
        $this->log = new Logger('my-log');
    }
    /**
     * Undocumented function
     *
     * @param string $filename
     * @param string $msg
     * @param array $context
     * @return void
     */
    public function writeLog($filename , $msg , $context){
        $logDir = storage_path('logs/'.$filename);
        if (!is_dir($logDir)) {
            mkdir($logDir, 0777, true);
        }
        $this->log->pushHandler(new StreamHandler($logDir . '/' . date('Y-m-d') . '.log', Logger::INFO));
        $this->log->log('info', $msg ,$context );
    }


}
